
package com.apes.scm.masterdata.car.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.plugin.soe.annotations.State;
import com.apes.framework.plugin.soe.annotations.States;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;


/**
 * 功能：配置车型
 *
 * @Auther: linwz
 * @Date: 2018/7/19 16:11
 */

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = CarConfiguration.CONST_TABLE_NAME)
public class CarConfiguration extends Model {
    public static final String CONST_TABLE_NAME = "mas_car_configuration";

    @Id
    @Column(name = "id",length = 15)
    @Comment("编码")
    private String id;

    @Name
    @Column(name = "name",length = 120,nullable = false)
    @Comment("名称")
    private String name;

    //车型配件代码
    @Column(name = "parts_code",length = 120,nullable = false)
    @Comment("车型配件代码")
    private String partsCode;

    //发动机型号
    @Column(name = "engine_model",length = 120)
    @Comment("发动机型号")
    private String engineModel;

    //变速器型号
    @Column(name = "transmission_model",length = 120)
    @Comment("变速器型号")
    private String transmissionModel;

    //发动机启停技术(0:没有;1：有)
    @Column(name = "STT",columnDefinition = "number(1,0) default 1")
    @Comment("发动机启停技术")
    private boolean STT;

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "drive", referencedColumnName = "id")
    @Comment("驱动")
    private Enumeration drive;//驱动(drive)(0:前轮驱动;1:后轮驱动;2:四轮驱动;3:适时四驱;4:全时四驱;5:分时四驱)

    //核定载人数
    @Column(name = "passenger_qty")
    @Comment("核定载人数")
    private String passengerQty;

    //厂牌
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "car_label_id",nullable = false, referencedColumnName = "id")
    @Comment("厂牌")
    private CarLabel carLabel;

    //车型
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "car_model_id", referencedColumnName = "id",nullable = false)
    @Comment("车型")
    private CarModel  carModel;

    //车辆类型
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "car_type_id", referencedColumnName = "id")
    @Comment("车辆类型")
    private CarType carType;

    //排放标准
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "emission_standard_id", referencedColumnName = "id")
    @Comment("排放标准")
    private EmissionStandard emissionStandard;

    //变速器描述
    @Comment("变速器描述")
    private String transmissionDescription;

    //车身颜色
    @Column(name = "body_color",length = 1000)
    @Comment("车身颜色")
    private String bodyColor;

    //生产年份
    @Column(name = "produce_year",nullable = false)
    @Comment("生产年份")
    private int produceYear;

    //前轮胎规格
    @Comment("前轮胎规格")
    private String frontWheelStandard;

    //后轮胎规格
    @Comment("后轮胎规格")
    private String rearWheelStandard;

    //燃料种类
    @Comment("燃料种类")
    private String fuelType;

    //排量（升）
    @Comment("排量")
    private String sweptVolume;

    //新车购置价
    @Comment("新车购置价")
    private Double newCarPurchase;

    @States(name = "有效标记", values = {
            @State(id = "valid", name = "有效"),
            @State(id = "invalid", name = "无效"),
            @State(id = "stopService", name = "停止服务"),
    })
    @Column(name = "valid_flag",length = 1000)
    @Comment("有效标记")
    private String validFlag = "valid";

    @Column(name = "NK", length = 4)
    @Comment("年款")
    private Integer NK;

    @Column(name = "YJFS", length = 16)
    @Comment("引进方式")
    private String YJFS;
}

